import { createRouter, createWebHistory } from 'vue-router'
import guard from './Guard'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'login',
      meta: {
        auth: false,  //导航守卫 false表示不需要登录 true表示需要登录
        // keepAlive: false //公共组件  false表示不需要 true表示需要
      },
      component: () => import('@/views/Login/Login.vue')

    },
    {
      path: '/main',
      name: 'main',
      redirect: '/main/MyHomePage',
       meta:{
            auth:true,  
            // keepAlive:false 
            },
      component: () => import('@/views/Main/index.vue'),
      children: [
        {
          path: 'MyHomePage',
          name: 'MyHomePage',
          meta:{
            auth:true,  
            // keepAlive:false 
            },
          component: () => import('@/views/Main/MyHomePage/MyHomePage.vue')

        },
        {
          path: 'Community',
          name: 'Community',
          meta:{
            auth:true,  
            // keepAlive:false 
            },
          component: () => import('@/views/Main/Community/Community.vue')
        },
        {
          path: 'Setting',
          name: 'Setting',
          meta:{
            auth:true,  
            // keepAlive:false 
            },
          component: () => import('@/views/Main/Setting/Setting.vue')

        },
        {
          path: 'ClassPage',
          name: 'ClassPage',
          meta:{
            auth:true,  
            // keepAlive:false 
            },
          component: () => import('@/views/Main/ClassPage/ClassPage.vue')

        },
        
      ]
    },
    {
      path: '/login',
      name: 'Login',
      meta:{
        auth:true,  
        // keepAlive:false 
        },
      component: () => import('@/views/Login/Login.vue')

    },
    {
      path: '/PersonalPage/:id',
      name: 'PersonalPage',
      meta:{
        auth:true,  
        // keepAlive:false 
        },
      component: () => import('@/views/Main/MyHomePage/PersonalPage.vue')

    },
  ]
})

export {
  router,
  guard
}
